//
//  GetNameByID.m
//  QRMaster
//
//  Created by myApple on 15/6/15.
//  Copyright (c) 2015年 myApple. All rights reserved.
//

#import "GetNameByID.h"
#import "OpertionPlist.h"

#import "communityModel.h"

@interface GetNameByID()
{
    NSArray * communityArray;
//    NSArray * bulidingArray;
}

@end

static GetNameByID * getName = nil;

@implementation GetNameByID

+(GetNameByID *)shareGetNameByID
{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        getName = [[super allocWithZone:NULL]init];
    });
    return getName;
}

-(NSString *)GetBulidingNameByID:(NSString *)GetNameByBulidingID  GetFloorName:(NSString *)GetNameByFloorID GetRoomName:(NSString *)GetNameByRoomid
{
    NSMutableString * allHouseName = [[NSMutableString alloc]init];
    for (NSDictionary * dict in self.bulidingArray) {
        if ([[dict objectForKey:@"buildingid"]isEqualToString:GetNameByBulidingID]) {
            [allHouseName appendString:[dict objectForKey:@"buildingname"]];
            NSArray * floors = [dict objectForKey:@"floors"];
            for (NSDictionary * fdict in floors) {
                if ([[fdict objectForKey:@"floorid"]isEqualToString:GetNameByFloorID]) {
                    [allHouseName appendString:@" "];
                    [allHouseName appendString:[fdict objectForKey:@"floorname"]];
                    NSArray * rooms = [fdict objectForKey:@"rooms"];
                    for (NSDictionary * rdict in rooms) {
                        if ([[rdict objectForKey:@"roomid"]isEqualToString:GetNameByRoomid]) {
                            [allHouseName appendString:@" "];
                            [allHouseName appendString:[rdict objectForKey:@"roomname"]];
                        }
                       
                    }
                }
            }
        }
    }
    return allHouseName;
}

@end
